/**
 * JAVACC DEMO 1.0
 */
package com.apache.client.common;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * description:
 *
 * @param <V>
 */
@SuppressWarnings("serial")
public class CaseInsensitiveMap<V> extends HashMap<String, V> {

    public CaseInsensitiveMap(){

    }

    public CaseInsensitiveMap(java.util.Map<? extends String, ? extends V> map){
        putAll(map);
    }

    public V put(String key, V value) {
        return super.put(key.toLowerCase(), value);
    }

    public void putAll(java.util.Map<? extends String, ? extends V> map) {
        int mapSize = map.size();
        if (mapSize == 0) {
            return;
        }
        for (Map.Entry<? extends String, ? extends V> e : map.entrySet()) {
            put(e.getKey(), e.getValue());
        }
    }

    // not @Override because that would require the key parameter to be of type Object
    public V get(String key) {
        return super.get(key.toLowerCase());
    }
}
